import { LoveTaskBaseBody } from "./LoveTaskBaseBody";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { ObjCreate } from "../common/ObjCreate";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { Cache } from "../../cache/Cache";
import { LoveTaskCommentList } from "./commentPanel/LoveTaskCommentList";
import { GScrollPane } from "../../../../com/mui/controls/GScrollPane";
import { ScrollPolicy } from "../../../../fl/controls/ScrollPolicy";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class LoveTaskCommentPanel
    
    export  class LoveTaskCommentPanel extends LoveTaskBaseBody
    {
        constructor()
        {
            super();
            return;
        }

        /* internal  */onOptBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.LoveTaskCommentReq, this._commentList.selectedData));
            return;
        }

        protected /* override */ initUI(): void
        {
            super.initUI();
            _titleTxt = ObjCreate.createTextField("", 0, 0, width, 100, this, _textFormat);
            _titleTxt.wordWrap = true;
            _titleTxt.multiline = true;
            _titleTxt.htmlText = HTMLUtil.addColor(Language.getStringByParam(21212, Cache.instance.loveTask.getTargetPlayerName(false, true)), "#F5BCBC");
            this._commentList = new LoveTaskCommentList();
            this._scrollPane = new GScrollPane();
            this._scrollPane.x = _titleTxt.x;
            this._scrollPane.y = _titleTxt.y + _titleTxt.textHeight + 10;
            this._scrollPane.width = width;
            this._scrollPane.height = 95;
            this._scrollPane.styleName = "GScrollPane";
            this._scrollPane.verticalScrollPolicy = ScrollPolicy.AUTO;
            this._scrollPane.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._scrollPane.source = this._commentList;
            this._scrollPane.scrollDrag = false;
            this._scrollPane.focusEnabled = false;
            addChild(this._scrollPane);
            this._optBtn = ObjCreate.createGButton(Language.getString(21211), 0, 0, 74, 24, this, "ButtonGreenStyle");
            this._optBtn.x = (width - this._optBtn.width) / 2;
            this._optBtn.y = this.height - 30;
            this._optBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onOptBtnClickHandler);
            return;
        }

        public /* override */ updateData(arg1: Array<any>=null): void
        {
            super.updateData(arg1);
            _titleTxt.htmlText = HTMLUtil.addColor(Language.getStringByParam(21212, Cache.instance.loveTask.getTargetPlayerName(false, true)), "#F5BCBC");
            this._commentList.updateData(arg1);
            return;
        }

        public /* override */ dispose(): void
        {
            this._commentList.dispose();
            return;
        }

        public /* override */ get bgH(): int
        {
            return 240;
        }

        public /* override */ get height(): number
        {
            return 170;
        }

        /* internal */ /* var */_commentList: LoveTaskCommentList;

        /* internal */ /* var */_scrollPane: GScrollPane;

        /* internal */ /* var */_optBtn: GButton;
    }
